using System;
using System.Collections.Generic;
using System.Text;
using FireStarter.CodeGeneration;
using NUnit.Framework;

namespace FireStarter.Test.CodeGeneration
{
    [TestFixture]
    public class TestFormTemplateLoader:TestBase
    {
        [Test]
        public void TestGetReadOnlyGridForm()
        {
            //---------------Set up test pack-------------------
            FormTemplateLoader templateLoader = new FormTemplateLoader();
            string namespaceName = GetRandomString();
            string boProjectName = GetRandomString();
            string className = GetRandomString();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string contents = templateLoader.GetReadOnlyGridForm(namespaceName, boProjectName, className);
            //---------------Test Result -----------------------

            AssertUiManagerCorrect(contents, namespaceName, boProjectName, className);
        }

        public static void AssertUiManagerCorrect(string contents, string namespaceName, string boProjectName, string className)
        {
            StringAssert.Contains(string.Format("using {0};", boProjectName), contents);
            StringAssert.Contains(string.Format("namespace {0}", namespaceName), contents);
            StringAssert.Contains(string.Format("public class {0}GridControlManager", className), contents);
            StringAssert.Contains(string.Format("public {0}GridControlManager(", className), contents);
            StringAssert.Contains(string.Format("BusinessObjectCollection<{0}> boCollection = Broker.GetBusinessObjectCollection<{0}>(\"\");", className), contents);
        }
    }
}
